//
// Created by ChaoDONG on 2021-03-17.
//

/* varwid.c -- uses variable-width output field */
/* varwid.c -- 使用变宽输出字段 */

#include <stdio.h>

int main(void){

    unsigned width, precision;

    int number = 256;

    double weight = 242.5;

    printf("Enter a field width:\n");

    scanf("%d", &width);

    printf("The number is :%*d:\n", width, number);
    /* 变量width提供字段宽度，number是待打印的数字。因为转换说明中*在
    d的前面，所以在printf()的参数列表中，width在number的前面*/

    printf("Now enter a width and a precision:\n");

    scanf("%d %d", &width, &precision);

    printf("Weight = %*.*f\n", width, precision, weight);


    printf("Done!\n");

    return 0;
}

